import { GameState } from "@sapi-game/gameState";
import { GameComponent } from "@sapi-game/main";
import { ScriptRunner } from "@sapi-game/Runner/scriptRunner";
import { WereWolfContext } from "@/werewolf/context";
import { WereWolfModule } from "@/werewolf/module";
import { WereWolfPlayer } from "@/werewolf/player";

export function isWereWolfPhaseView(
    comp: GameComponent<any, any>
): comp is WereWolfPhaseView {
    return (comp as unknown as WereWolfPhaseView).runPhaseView != undefined;
}

export abstract class WereWolfPhaseView<
    S extends GameState<WereWolfPlayer, WereWolfContext> = GameState<
        WereWolfPlayer,
        WereWolfContext
    >,
    O = unknown
> extends WereWolfModule.Component<O, S> {
    get players() {
        return this.context.players;
    }

    override onAttach(): void {
        this.runner.run(async (r) => {
            await this.runPhaseView(r);
        });
    }

    async runPhaseView(r: ScriptRunner): Promise<void> {}
}
